package visitor;

/**
 * 计算周长的 Visitor
 */
public class PerimeterCalculatorVisitor implements Visitor {
    @Override
    public void visitCircle(Circle circle) {
        double perimeter = 2 * Math.PI * circle.getRadius();
        System.out.println("Perimeter of circle: " + perimeter);
    }

    @Override
    public void visitRectangle(Rectangle rectangle) {
        double perimeter = 2 * (rectangle.getWidth() + rectangle.getHeight());
        System.out.println("Perimeter of rectangle: " + perimeter);
    }
}